﻿<%@ page contentType="text/html; charset=UTF-8" %>

<!-- 消息提醒 -->


<div class="bar_seach_div">

查询条件：<input id="s_vipmsg_content" name="s_vipmsg_content" type="text" class="box-input">&nbsp;&nbsp;
<input id="s_vipmsg" type="button" class="btns" value="查  询">
</div>

<div style="padding: 5px;"><table id="vipmsg_grid"></table></div>   
<div style="padding: 5px;"><div id="vipmsg_page"></div>


<div id="vipmsg_dialog_index" title=" 消息提醒操作"  class="easyui-dialog" >
<form id="vipmsg_form_index" name="vipmsg_form_index" style="width:326px;" class="ui-form" method="POST">
    <div id="vipmsg_index_errmsg"></div>
    <table width="100%" align="center" border="0" cellspacing="0" cellpadding="0" class="jkt-tableStyle">

	<tr>
        <td class="bluetd" align="right">内容：</td>
        <td class="bluetd" align="left">
          <input id="vipmsg_content_index"  class="easyui-validatebox" type="text"/>
        </td>
     </tr>     <tr>
        <td class="bluetd2" align="right">会员ID：</td>
        <td class="bluetd2" align="left">
          <input id="vipmsg_menberId_index"  class="easyui-validatebox" data-options="required:true"  type="text" />
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">创建时间：</td>
        <td class="bluetd" align="left">
          <input id="vipmsg_creatTime_index"  class="easyui-validatebox" type="text"/>
        </td>
     </tr>
      <tr>
        <td colspan="2" align="center">
         <input type="button" class="btns" id="vipmsg_index_bt" value="提  交" style="margin-top:8px;" />&nbsp;&nbsp;
         <input type="button" class="btns" id="vipmsg_close" value="关  闭" style="margin-top:8px;" />
      </td>
</tr>
</table>
</form>
</div> 

<script>

	//关闭弹出窗口
	closeUIDialog('vipmsg_dialog_index');
    var vipmsgvalidate,vipmsgids='',vipmsgsave=true;//本页面变量
     /**jqGrid列表*/
	jQuery("#vipmsg_grid").jqGrid({
		// caption: 
	    //     '<a href="javascript:fun_vipmsg_add()"  class="easyui-linkbutton" data-options="plain:true,iconCls:\'icon-edit\'">新增</a>' +
	    //     '<a href="javascript:fun_vipmsg_update()" class="easyui-linkbutton" data-options="plain:true,iconCls:\'icon-save\'">修改</a>' +
	    //     '<a href="javascript:fun_vipmsg_delete()" class="easyui-linkbutton" data-options="plain:true,iconCls:\'icon-cancel\'">删除</a>',
        datatype: "json", //JSON格式数据
        hidegrid: false, //不显示收缩
        url:'barapp/VipMsg/list.do', //请求后台返回列表数据的URL 
        forceFit: false,//调整宽度不改变表格宽度
        //width: jqGridWidth,   //resources/js/constant.js
        //height: jqGridHeight, //resources/js/constant.js
        autowidth:false,   //取消容器的自动宽度
        colNames:[
        '编号'
        ,'内容'
        ,'会员名'
        ,'会员ID'
        ,'创建时间'
        //,'操作'
	    ],
	    //要呈现字段的属性设置
	    //sortable:设置该字段是否进行排序,sorttype:排序的数据类型 
        colModel:[
        {name:'id',index:'id', width:2,sorttype:'int',sortable:false}  
        ,{name:'content',index:'content',width:80,sortable:false}
        
        ,{name:'menberName',index:'menberName',width:80,sortable:false}
        ,{name:'menberId',index:'menberId',width:80,sortable:false}
        ,{name:'creatTimeString',index:'creatTimeString',width:90,sortable:false}
        //,{name:'act',        index:'act',   align:'center',     width:150}
        ],
        multiselect: true,//禁止多选
        multiboxonly:true,
        toolbar:[true,'top'],
        rowNum:10, 
        rowList:[10,20,30,50,100,500], 
        viewrecords: true, 
        sortname:  "id" , //默认排序的列名    
        sortorder: "desc", 
        pager: '#vipmsg_page', 
        jsonReader: {     
          root: 'dataRows',   
          repeatitems : false     
        }
        //,caption:'消息提醒 列表'       
       // ,gridComplete: function(){  
          //  var ids = $("#vipmsg_grid").jqGrid('getDataIDs');  
           // for(var i=0, j=ids.length; i < j; i++){  
              //  var cl = ids[i];  
               // be = "<input style='height:22px;width:40px;' type='button' value='编辑' onclick=\"fun_vipmsg_update();\"  />&nbsp;&nbsp;";   
                //se = "<input style='height:22px;width:40px;' type='button' value='保存' onclick=\"$('#jqGridId').saveRow('"+cl+"');\"  />&nbsp;&nbsp;";  
               // se = "<input style='height:22px;width:40px;' type='button' value='删除' onclick=\"fun_vipmsg_delete();\"  />&nbsp;&nbsp;";   
               // ce = "";
                //$("#vipmsg_grid").jqGrid('setRowData',ids[i], {act: be + se + ce});  
           // }
        //}
    })
    
    $("#t_vipmsg_grid").removeClass("ui-userdata ui-state-default"); //删样式
	$("#t_vipmsg_grid").append("<div style='height:32px;' class='ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix'><span class='ui-jqgrid-title'>"
	  //+"<a data-options='plain:true,iconCls:\'icon-edit\'' class='easyui-linkbutton l-btn l-btn-plain' href='javascript:fun_vipmsg_add()' group='' id=''><span class='l-btn-left'><span class='l-btn-text icon-edit l-btn-icon-left'>新增</span></span></a>"
	  //+"<a data-options='plain:true,iconCls:\'icon-save\'' class='easyui-linkbutton l-btn l-btn-plain' href='javascript:fun_vipmsg_update()' group='' id=''><span class='l-btn-left'><span class='l-btn-text icon-save l-btn-icon-left'>修改</span></span></a>"
	  +"<a data-options='plain:true,iconCls:\'icon-cancel\'' class='easyui-linkbutton l-btn l-btn-plain' href='javascript:fun_vipmsg_delete()' group='' id=''><span class='l-btn-left'><span class='l-btn-text icon-cancel l-btn-icon-left'>删除</span></span></a>"
	  +"</span></div> ");//列表头

    //$("#t_vipmsg_grid").append("<div class='bar_grid_add_div' > <a href='javascript:void(0)' onclick=\"fun_vipmsg_add()\" >新增</a></div>");//列表头
    //$("#t_vipmsg_grid").hide();//隐藏标题栏
    jQuery("#vipmsg_grid").jqGrid('hideCol',['menberId','id']);//隐藏列
    $("#vipmsg_grid").closest(".ui-jqgrid-bdiv").css({ 'overflow-x' : 'hidden' });//隐藏横向滚动条
    
    var vipmsg_list_saveflag = true;
    
    /***/
    $('#vipmsg_index_bt').unbind('click');
    
    /**新增操作-打开窗口*/
    function fun_vipmsg_add(){
		$("#vipmsg_form_index")[0].reset();
		vipmsg_list_saveflag = true;
        openUIDialog('vipmsg_dialog_index', true, 460, 320);
	}
    //关闭窗口
    $('#vipmsg_close').click(function(){
        $("#vipmsg_dialog_index").dialog('close');
    })
    
    /**点击按妞*/
    $('#vipmsg_index_bt').click(function(){
         //if(rulesByValidator(vipmsgvalidate)){
             if(vipmsgsave){
                 vipmsg_add_submit();
             }else{
                 vipmsg_update_submit();
             }
         //}
     })
     
     //新增提交
     function  vipmsg_add_submit(){
        var vipmsgJson="{'id':'','content':'"+$('#vipmsg_content_index').val()+"','menberId':'"+$('#vipmsg_menberId_index').val()+"'}";  
         $.ajax({
             type: "POST",
             url:"barapp/VipMsg/save.do",
             data:{
                 vipmsgJson : vipmsgJson
             },
             dataType: "json",
             contentType: "application/x-www-form-urlencoded; charset=UTF-8",
             success:function(json){
                 if(json.success){
                     $("#vipmsg_grid").trigger("reloadGrid");
                     $.messager.alert('操作提示', '操作成功!');
                 }else{
                	 $.messager.alert('操作提示', '操作失败!');
                 }
             }
         })
     }
     

     /**修改操作*/
     function fun_vipmsg_update(){
         var id =$("#vipmsg_grid").jqGrid('getGridParam','selrow');
         if(typeof(id) =="string"){
             rowData=jQuery("#vipmsg_grid").jqGrid('getRowData',id);  
 		    //$("#vipmsg_dialog_index").dialog('option' , 'title',['修改 消息提醒']);
 		    $("#vipmsg_form_index")[0].reset();
 		    //vipmsgvalidate.resetForm(); //重置验证状态
 		    //$("#vipmsg_dialog_index").dialog("open");
 		    openUIDialog('vipmsg_dialog_index', true, 460, 320);
             load_vipmsg_data();
             vipmsgsave=false;
         }else{
        	 $.messager.alert('操作提示', '请至少选择一条记录再操作!'); 
         }
 	}
   /**修改加载数据*/
 	function load_vipmsg_data(){
 	  $("#vipmsg_content_index").val(rowData.content);
 	  $("#vipmsg_menberId_index").val(rowData.menberId);
          
 	}
    //修改提交
    function  vipmsg_update_submit(){
        var vipmsgJson="{'id':'"+rowData.id+"','content':'"+$('#vipmsg_content_index').val()+"','menberId':'"+$('#vipmsg_menberId_index').val()+"'}";  
        $.ajax({
            type: "POST",
            url:"barapp/VipMsg/update.do",
            data:{
                vipmsgJson : vipmsgJson
            },
            dataType: "json",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            success:function(json){
                if(json.success){
                    $("#vipmsg_grid").trigger("reloadGrid");
                    $.messager.alert('操作提示', '操作成功!'); 
                }else{
               	 $.messager.alert('操作提示', '操作失败!'); 
                }
            }
       })
    }
	 
	 
	//删除-开始-验证
	function fun_vipmsg_delete(){
       
        
	      var gr = $("#vipmsg_grid").jqGrid('getGridParam','selrow');
	      if(gr != null)
	      {
	         var rowData = jQuery("#vipmsg_grid").jqGrid('getRowData', gr);
	         $.messager.confirm('删除提示','您确认要删除?', function(r)
	         {
	            if(r)
	            {
	            	fun_vipmsg_del(rowData.id);
	            }
	         });
	      }
	      else
	      {
	         $.messager.alert('提示','请先选中一行数据!!');
	      }
        
    }
	//删除-提交数据-操作
    function fun_vipmsg_del(ids){
	    $.ajax({
            type: "POST",
            url:"barapp/VipMsg/delete.do?s_ids="+ids,
            dataType: "json",
            data:{
            	ids : ids
            },
            success:function(json){
                 if(json.success){
                	  $.messager.alert('操作提示', '操作成功！');
                      $("#vipmsg_grid").trigger("reloadGrid");
                 }else{
                	  $.messager.alert('操作提示', '操作失败！');
                 }
            }
        })
    }
    

	
 


	
	//注意:web服务器 utf-8配置
	$('#s_vipmsg').click(function(){
         var s_content=encodeURI($('#s_vipmsg_content').val());
         $("#vipmsg_grid").setGridParam({url:'barapp/VipMsg/list.do?s_content='+s_content});
         $("#vipmsg_grid").trigger("reloadGrid");
    })
    
    /** jqgrid宽度高度自适应 begin */ 
    doResize();
	var t=document.documentElement.clientWidth;  
	window.onresize = function(){  
		if(t != document.documentElement.clientWidth){ 
		t = document.documentElement.clientWidth; 
		doResize(); 
		} 
	} 
    
	function doResize() { 
		var ss = getPageSize(); 
		$("#vipmsg_grid").jqGrid('setGridWidth', ss.WinW-350).jqGrid('setGridHeight', ss.WinH-300); 
	}
	
	function getPageSize() { 
		//http://www.blabla.cn/js_kb/javascript_pagesize_windowsize_scrollbar.html 
		var winW, winH; 
		if(window.innerHeight) {// all except IE 
		winW = window.innerWidth; 
		winH = window.innerHeight; 
		} else if (document.documentElement && document.documentElement.clientHeight) {// IE 6 Strict Mode 
		winW = document.documentElement.clientWidth; 
		winH = document.documentElement.clientHeight; 
		} else if (document.body) { // other 
		winW = document.body.clientWidth; 
		winH = document.body.clientHeight; 
		}  // for small pages with total size less then the viewport  
		return {WinW:winW, WinH:winH}; 
	}
	/** jqgrid宽度高度自适应 begin */
     
</script>
